<?php
include_once("doubles.php");
if(class_exists('SQL_Helper') != true)
{
   include_once("sql_helper.php");
}
class DoublesRepository
{
	function createDoubles($round_scheduleID, $gameNumber, $team1Points, $team2Points){
		SQL_Helper::executeNonQuery("INSERT INTO `doubles_match_result` (`doubles_matchID`, `round_scheduleID`, `gameNumber`, `team1Points`, `team2Points`) VALUES(null,?,?,?,?)",$round_scheduleID, $gameNumber, $team1Points, $team2Points);
	}
	
	function readDoubles($doubles_matchID){
		return SQL_Helper::executeQuerySingle("Select * from `doubles_match_result` where `doubles_matchID` = ?", $doubles_matchID);
	}
	
	function updateDoubles($round_scheduleID, $gameNumber, $team1Points, $team2Points){
		SQL_Helper::executeNonQuery("Update `doubles_match_result` set `team1Points`=?, `team2Points`=? where `round_scheduleID` = ? and `gameNumber`=? ",$team1Points, $team2Points, $round_scheduleID, $gameNumber);
	}
	
	function deleteGame($doubles_matchID){
		SQL_Helper::executeNonQuery("delete from `doubles_match_result` where `doubles_matchID` = ?", $doubles_matchID);
	}
	
	function map($row){
		$class= "Doubles";
		return SQL_Helper::sql_map($row,$class);
	}
	function maps($rows){
		$class= "Doubles";
		return SQL_Helper::sql_maps($rows,$class);
	}
	
	function getDoublesByScheduleIDAndGameNo($round_scheduleID, $gameNumber){
		return SQL_Helper::executeQuery("Select * from `doubles_match_result` where `round_scheduleID` = ? and `gameNumber` = ?", $round_scheduleID, $gameNumber);
	}
	
	function getDoublesByScheduleID($round_scheduleID){
		return SQL_Helper::executeQuery("Select * from `doubles_match_result` where `round_scheduleID` = ? ", $round_scheduleID);
	}
}
?>